//
// Created by Administrator on 2021/5/18.
//
#include <queue>
#include <iostream>
using namespace std;
class SeatManager {
private:
    priority_queue<int,vector<int>,greater<>>pq;
public:
    SeatManager(int n) {
        for(int i = 1;i<=n;++i) pq.push(i);
    }

    int reserve() {
        int ans = pq.top();
        pq.pop();
        return ans;
    }

    void unreserve(int seatNumber) {
        pq.push(seatNumber);
    }
};

/**
 * Your SeatManager object will be instantiated and called as such:
 * SeatManager* obj = new SeatManager(n);
 * int param_1 = obj->reserve();
 * obj->unreserve(seatNumber);
 */

int main()
{
    auto obj = new SeatManager(5);
    cout << obj->reserve() << endl;
    cout << obj->reserve() << endl;
    obj->unreserve(2);
    cout << obj->reserve() << endl;
    cout << obj->reserve() << endl;
    cout << obj->reserve() << endl;
    cout << obj->reserve() << endl;
    obj->unreserve(5);
    delete obj;
    return 0;
}